// Flippers for a pinball machine
//
// (c)2012 Felipe Sanches <fsanches@metamaquina.com.br>
// licensed under GPLv3 or later

module flipper(angle=35, L=90, R=10, r=5, H=24, h=8, rubber_r=4, rubber_color="black"){
  rotate([0,0,angle]){
    flipper_body(L, R, r, H, h, rubber_r);
    flipper_rubber(L, R, r, H, h, rubber_r, rubber_color);
  }
  flipper_shaft();
}

module flipper_body(L=90, R=10, r=5, H=22, h=8, rubber_r=4){
	difference(){
		union(){
			linear_extrude(height=H)
			flipper_outline(L, R, r);

			linear_extrude(height=h)
			flipper_outline(L + 2*rubber_r, R + rubber_r, r + rubber_r);
		}
	
		//TODO hole for metalic axis
		//translate([0,0,...])
		//cylinder(r=..., h=...);
	}
}

//TAITO:
// L=75.5
// R=15.5
// r=7.7

module flipper_rubber(L=90, R=10, r=5, H=22, h=8, rubber_r=4, rubber_color="black"){
  color(rubber_color)
  translate([0, 0, h])
	linear_extrude(height=H-h)
	difference(){
  	flipper_outline(L + 2*rubber_r, R + rubber_r, r + rubber_r);
		flipper_outline(L, R, r);
	}
}

module flipper_shaft(radius=5.9/2, length=50){
  color("grey") //metalic color
  translate([0,0,-length])
  cylinder(r=radius, h=length, $fn=20);
}

module flipper_outline(L, R, r){
	hull(){
		circle(r=R);
		translate([L-r-R,0])
		circle(r=r);
	}
}

module flipper_mount_holes(playfield_thickness=15){
  translate([0,0,-playfield_thickness-1]){
    cylinder(r=6, h=playfield_thickness+2);
  }
}

left_flipper(R=15, L=150, rubber_color="darkred");
